<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/taglibs.jsp"%>

<html>
	<head>
		<link href="${ctx}/css/main.css" rel="stylesheet" type="text/css" />
	</head>
    <script language="javascript">
		function submitAction(action){
			document.contentMainForm.action = action ;
			document.contentMainForm.submit();
		}
		
		function select(action,id){
			location.href = "${ctx}/" + action + "?id=" + id;
		}
		
		function init(){
			document.getElementById("adDesc").value = "";
			document.getElementById("adType").value = "";
		}
		
		function doDelete(action,id){
			if(confirm('是否确认删除？')){
				location.href = "${ctx}/" + action + "?id=" + id ;
			}
		}
		
		function clickFile(action,fileName){
			location.href = "${ctx}/" + action + "?fileName=" + fileName;
		}
	</script>	
	
	<body>
		<form method="post" action="" name="contentMainForm">
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td width="20%" class="td2">  
						文件描述 
					</td>
					<td width="30%" class="td2">
						<input type="text" name="adDesc" size="32" value="${adManage.adDesc}">
					</td>
					<td width="20%" class="td2"> 
						文件类型
					</td>
					<td width="30%" class="td2">
						<select name="adType" id="adType" style="width:200px">
							<option value="" />
							<c:forEach var ="adType" items="${sessionScope.T_adTypeList}">
								<c:if test="${adManage.adType == adType.typeCode}">
									<option value="${adType.typeCode}" selected="selected">${adType.typeName}</option>
								</c:if>
								<c:if test="${adManage.adType != adType.typeCode}">
									<option value="${adType.typeCode}">${adType.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td class="td11" align="left" colspan="4">
						<input type="button" name="find" value="查询" onClick="submitAction('searchAd.ac');">
						&nbsp;&nbsp;<input type="button" name="new" value="新增" onClick="submitAction('detailAd.ac');">
						&nbsp;&nbsp;<input type="button" name="reset" value="重置" onClick="init()" >
					</td>
				</tr>		
			</table>
			<BR>
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td width="10%" class="td1" align="center">
						动作
					</td>
					<td width="15%" class="td1" align="center">
						广告类型
					</td>
					<td width="25%" class="td1" align="center">
						广告描述
					</td>
					<td width="20%" class="td1" align="center">
						广告位置
					</td>
					<td width="20%" class="td1" align="center">
						文件名
					</td>
					<td width="10%" class="td1" align="center">
						删除
					</td>
				</tr>
				<c:forEach var="ad" items="${adList}">
					<tr>
						<td width="10%" class="td2" align="center">
							<a href="javascript:select('selectAd.ac','${ad.id}');">选择</a>
						</td>
						<td width="15%" class="td2" align="center">
							${ad.adType }
						</td>
						<td width="25%" class="td2" align="center">
							${ad.adDesc }
						</td>
						<td width="20%" class="td2" align="center">
							${ad.adLocation }
						</td>
						<td width="20%" class="td2" align="center">
							<a href="javascript:clickFile('getAdContent.ac','${ad.adFilename}');">${ad.adFilename}</a>
						</td>
						<td class="td2" align="center">
							<img src="${ctx}/images/delete0.png" onclick="javascript:doDelete('deleteAd.ac','${ad.id}');">
						</td>
					</tr>
				</c:forEach>
			</table>
		</form>
	
	</body>
</html>